import request from '@/utils/request'
import storage from 'store'
import { ACCESS_TOKEN_TEMP } from '@/store/mutation-types'

export function getRolesList (parameter) {
  return request({
    url: '/boss/system/role/list',
    method: 'post',
    data: parameter
  })
}

export function apiGetRoleListByUser (parameter) {
  return request({
    url: '/boss/pro/role/roleDropDownBoxByUser',
    method: 'get',
    params: parameter
  })
}
export function joinProject (parameter) {
  return request({
    url: '/boss/project/info/join',
    method: 'post',
    data: parameter
  })
}
export function getUserList (parameter) {
  return request({
    url: '/boss/system/user/list',
    method: 'post',
    data: parameter
  })
}
export function addUser (parameter) {
  return request({
    url: '/boss/system/user/add',
    method: 'post',
    data: parameter
  })
}
export function addUserFast (parameter) {
  return request({
    url: '/boss/project/team/addAdmin',
    method: 'post',
    data: parameter
  })
}
export function updateUser (parameter) {
  return request({
    url: '/boss/system/user/update',
    method: 'post',
    data: parameter
  })
}
export function getOrgList (parameter) {
  return request({
    url: '/common/listOrgInfo',
    method: 'post',
    data: parameter
  })
}
export function getSponsorList (parameter) {
  return request({
    url: '/boss/org/info/listOrg',
    method: 'post',
    data: parameter
  })
}
export function getAreaList (parameter) {
  return request({
    url: '/common/listOrgAreaInfo',
    method: 'post',
    data: parameter
  })
}
export function switchStatus (parameter) {
  return request({
    url: '/boss/system/user/status/update',
    method: 'post',
    data: parameter
  })
}

/**
 * 修改密码接口 优先取临时 token，如果有新的 token 会覆盖
 * @param parameter
 * @return {*}
 */
export function updatePassword (parameter) {
  return request({
    url: '/boss/system/user/pwd/update',
    method: 'post',
    data: parameter,
    headers: {
      token: storage.get(ACCESS_TOKEN_TEMP)
    }
  })
}
export function userImport (parameter) {
  return request({
    url: '/boss/system/user/import',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
export function userExport (parameter) {
  return request({
    url: '/boss/system/user/export',
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}
export function resetPwd (parameter) {
  return request({
    url: '/boss/system/user/pwd/reset',
    method: 'post',
    data: parameter
  })
}

export function listAll (parameter) {
  return request({
    url: '/boss/system/user/listAll',
    method: 'get',
    params: parameter
  })
}

